package com.lanchuan.soft.service.impl;

import com.lanchuan.soft.dao.IDictionaryDao;
import com.lanchuan.soft.entity.Dictionary;
import com.lanchuan.soft.service.IDictionaryService;
import com.lanchuan.soft.utils.SystemConstant;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Log4j2
public class DictionaryService implements IDictionaryService {

    private IDictionaryDao dictionaryDao;

    @Autowired
    public DictionaryService(IDictionaryDao dictionaryDao) {
        this.dictionaryDao = dictionaryDao;
    }

    @Override
    public Map<String, Object> findEventTypeList() {

        Map<String, Object> resultMap = new HashMap<>();

        try {
            List<Dictionary> userList = dictionaryDao.findListByType(SystemConstant.DICTIONARY_TYPE_EVENT_TYPE);
            resultMap.put("list", userList);

            resultMap.put("errcode", SystemConstant.SUCCESS);
            return resultMap;
        } catch (Exception e) {
            log.error("DictionaryService / findEventTypeList", e);
            resultMap.put("errcode", SystemConstant.UNKNOWN_ERROR);
            return resultMap;
        }
    }
}
